// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui'
import axios from 'axios'
import VueAxios from 'vue-axios'
import 'element-ui/lib/theme-chalk/index.css'
import VueCookies from 'vue-cookies'
import store from './store'
import Vuex from 'vuex'
import echarts from 'echarts'
// import 'http://route-docker.dev.oraro.net/agriexp-service-hdfs-api/jquery.min.js'
// import 'http://route-docker.dev.oraro.net/agriexp-service-hdfs-api/pageoffice.js'

Vue.use(VueAxios, axios)
Vue.use(ElementUI)
Vue.config.productionTip = false
Vue.use(VueCookies)
Vue.use(Vuex)
Vue.prototype.$cookie = VueCookies
import $ from 'jquery'
Vue.prototype.$echarts = echarts
window.eventBus = new Vue()

Vue.prototype.formatDate = (date) => {
    var year = new Date(date).getFullYear()
    var month = new Date(date).getMonth() + 1
    var day = new Date(date).getDate()
    month = month < 10 ? '0' + month : month
    day = day < 10 ? '0' + day : day
    return `${year}-${month}-${day}`
}
Vue.prototype.formatDateTime = (date) => {
    var year = new Date(date).getFullYear()
    var month = new Date(date).getMonth() + 1
    var day = new Date(date).getDate()
    var hour = new Date(date).getHours()
    var minute = new Date(date).getMinutes()
    var seconds = new Date(date).getSeconds()
    month = month < 10 ? '0' + month : month
    day = day < 10 ? '0' + day : day
    hour = hour < 10 ? '0' + hour : hour
    minute = minute < 10 ? '0' + minute : minute
    seconds = seconds < 10 ? '0' + seconds : seconds
    return `${year}-${month}-${day} ${hour}:${minute}:${seconds}`
}
/*
** randomWord 产生任意长度随机字母数字组合
** randomFlag-是否任意长度 min-任意长度最小位[固定位数] max-任意长度最大位
*/

Vue.prototype.randomWord = (randomFlag, min, max) => {
    var str = "",
        range = min,
        arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];

    // 随机产生
    if (randomFlag) {
        range = Math.round(Math.random() * (max - min)) + min;
    }
    for (var i = 0; i < range; i++) {
        let pos = Math.round(Math.random() * (arr.length - 1));
        str += arr[pos];
    }
    return str;
}

Vue.prototype.randomEng = (randomFlag, min, max) => {
    var str = "",
      range = min,
      arr = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];

    // 随机产生
    if (randomFlag) {
        range = Math.round(Math.random() * (max - min)) + min;
    }
    for (var i = 0; i < range; i++) {
        let pos = Math.round(Math.random() * (arr.length - 1));
        str += arr[pos];
    }
    return str;
}
import api from './utils/api'
import http from './utils/http'
import httpRequest from '@/utils/httpRequest'
import {isAuth} from '@/utils'
import packageJson from '../package.json'

Vue.prototype.api = api
Vue.prototype.http = http
Vue.prototype.$httpRequest = httpRequest // ajax请求方法
Vue.prototype.isAuth = isAuth     // 权限方法
Vue.prototype.packageJson = packageJson //package配置文件

import _ from 'lodash'

Vue.use(_)

Vue.component('remote-script', {   //pageOffice用
    render: function (createElement) {
        var self = this
        return createElement('script', {
            attrs: {
                type: 'text/javascript',
                src: this.src,
                id: this.id
            },
            on: {
                load: function (event) {
                    self.$emit('load', event)
                },
                error: function (event) {
                    self.$emit('error', event)
                },
                readystatechange: function (event) {
                    if (this.readyState == 'complete') {
                        self.$emit('load', event)
                    }
                }
            }
        })
    },
    props: {
        src: {
            type: String,
            required: true
        },
        id: {
            type: String
        }
    }
})

/* eslint-disable no-new */
new Vue({
    el: '#app',
    router,
    store,
    components: {App},
    template: '<App/>'
})
